//
//  CMDBEmptyView.swift
//  CMDB
//
//  Created by 王磊 on 25/05/2017.
//  Copyright © 2017 CMDB. All rights reserved.
//

import UIKit
private var CMDB_Build_Margin: CGFloat = (CMDB_Screen_Width - 630 * CMDB_Rate) * 0.5
class CMDBBuildUserManageView: UIView {
    
    private var textLabel: UILabel = UILabel()
    
    private var buildItem: UIButton = UIButton(type: .Custom)
    
    var text: String = "" {
        
        willSet {
            
            textLabel.text = newValue
        }
    }
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        configOwnSubviews()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
extension CMDBBuildUserManageView {
    
    override func configOwnSubviews() {
        
        addSubview(textLabel)
        
        addSubview(buildItem)
        
        textLabel.textColor = word38Color
        
        textLabel.textAlignment = .Center
        
        textLabel.font = CMDB_15_FONT
        
        buildItem.setTitle("新建", forState: .Normal)
        buildItem.setTitle("新建", forState: .Highlighted)
        
        buildItem.setTitleColor(UIColor.Hex6(0xffffff, alpha: 0.54), forState: .Highlighted)
        
        buildItem.setTitleColor(UIColor.Hex6(0xffffff), forState: .Normal)
        
        buildItem.backgroundColor = UIColor.Hex6(0xff6d00, alpha: 54)
        
        buildItem.titleLabel!.font = CMDB_17_FONT
        
        buildItem.addTarget(self, action: #selector(buildTriggered), forControlEvents: .TouchUpInside)
        
        buildItem.layer.cornerRadius = 5
        
        //
        
    }
}
extension CMDBBuildUserManageView {
    
    @objc private func buildTriggered() {
        
        let argu = TSArguInfo()
        
        argu.view = self
        
        argu.itemType = .ButtonItem
        
        performSelWithArgu(argu)
    }
    
}

extension CMDBBuildUserManageView {
    
    override func layoutSubviews() {
        super.layoutSubviews()
        
        textLabel.snp_makeConstraints { (make) in
            
            make.left.equalTo(0 )
            
            make.right.equalTo(0)
            
            make.top.equalTo(40)
            
            make.height.equalTo(40)
        }
        buildItem.snp_makeConstraints { [weak self] (make) in
            
            make.left.equalTo(CMDB_Build_Margin)
            
            make.right.equalTo(-CMDB_Build_Margin)
            
            make.height.equalTo(88 * CMDB_Rate)
            
            make.top.equalTo(self!.textLabel.snp_bottom).offset(40)
        }
    }
    
}
